package java_DesignPattern.BehavioralPattern.IteratorPattern;

/**
 * 迭代器模式---测试类
 */
public class Test {

    public static void main(String[] args) {
        StudentContext context = new StudentContext();
        context.add(new Student("张三", 18));
        context.add(new Student("李四", 19));
        context.add(new Student("王五", 20));

        Iterator<Student> iterator = context.getIterator();
        while (iterator.hasNext()) {
            Student student = iterator.next();
            System.out.println(student.getName() + " " + student.getAge());
        }
    }
}
